



def get_breadcrumb(category):
    '''获取面包屑导航'''
    breadcrumb=dict(
        cat1='',
        cat2='',
        cat3=''
    )
    # 面包屑导航分三层
    # 如果category上层查不到，则表示category为最高层cat1
    if category.parent is None:
        breadcrumb['cat1']=category
    #     如果category.subs查不出数据，则表示为第三层
    elif category.subs.count()==0:
        breadcrumb['cat3'] = category
        cat2=category.parent
        breadcrumb['cat2']=cat2
        breadcrumb['cat1']=cat2.parent
    else:
        breadcrumb['cat2']=category
        breadcrumb['cat1']=category.parent
    return breadcrumb